package com.mlc.core.serviceImpl;

import com.mlc.core.service.SingersService;
import com.mlc.data.dao.SingersDao;
import com.mlc.data.entity.Singers;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Optional;

/**
 * @author FireWang
 * @date 2022/03/14 02:46:46
 */
@Service
@AllArgsConstructor
@Transactional
public class SingersServiceImpl implements SingersService {
    private SingersDao singersDao;

    @Override
    public List<Singers> getAll() {
        return singersDao.findAll();
    }

    @Override
    public Singers getById(Integer id) {
        Optional<Singers> singers = singersDao.findById(id);
        return singers.get();
    }

    @Override
    public void insert(Singers singers) {
        singersDao.save(singers);
    }

    @Override
    public void update(Singers singers) {
        singersDao.save(singers);
    }

    @Override
    public void deleteById(Integer id) {
        singersDao.deleteById(id);
    }
}